<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        tr,td{
            text-align: center;
        }
    </style>
</head>
<body>

    <input type="text" id="text" >

    <table border="1px"cellpadding="0" cellspacing="0" >
        <tbody id="table-tby">
            <tr>
                <td>序号</td>
                <td>内容</td>
                <td>输入</td>
            </tr>

        </tbody>
    </table>

<script>

    window.index = 0;
    var elementById = document.getElementById("text");
    elementById.addEventListener("keydown",function (e) {
        console.log(e);
            var text = elementById.value;
        if(e.keyCode == 13 && text != "" && text != undefined && text != null){
            window.index++;
            let html =
                "                <td>"+ window.index +"</td>\n" +
                "                <td>test</td>\n" +
                "                <td>"+ text +"</td>\n" ;
            let tr = document.createElement("tr");
            tr.innerHTML = html;
            document.getElementById("table-tby").appendChild(tr);
            elementById.value = "";
        }
    });
</script>

</body>
</html>